package com.example.music.controller;

import com.example.music.domain.IogInformation;
import com.example.music.service.IIogInformationService;
import com.example.music.util.AjaxResult;
import com.example.music.util.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Anonymous
@Api(tags = "订单物流信息管理(224 魏川子)")
@RestController
@RequestMapping("/api/IogInformation")
public class IogInformationController {
    @Autowired
    private IIogInformationService iogInformationService;

    @ApiOperation(value = "获取所有物流信息(224 魏川子)",notes = "获取所有物流信息")
    @GetMapping("/list")
    public AjaxResult list(){
        return AjaxResult.success(iogInformationService.getIogInformation());
    }

    @ApiOperation(value = "根据id查找物流信息(224 魏川子)",notes = "根据id查找物流信息")
    @GetMapping("/{id}")
    public AjaxResult getIogInformationById(@PathVariable("id") Long id){
        return AjaxResult.success(iogInformationService.selectIogInformationById(id));
    }

    @ApiOperation(value = "新增一个物流信息 (224 魏川子)",notes = "新增一个物流信息")
    @PostMapping("/insert")
    public AjaxResult insertIogInformation(@RequestBody IogInformation iogInformation){
        return AjaxResult.success(iogInformationService.insertIogInformation(iogInformation));
    }

    @ApiOperation(value = "更新一个物流信息(224 魏川子)",notes = "更新一个物流信息")
    @PutMapping("/update")
    public AjaxResult updateIogInformation(@Validated @RequestBody IogInformation iogInformation){
        return AjaxResult.success(iogInformationService.updateIogInformation(iogInformation));
    }

    @ApiOperation(value = "删除一个物流信息(224 魏川子)",notes = "删除一个物流信息")
    @DeleteMapping("/{id}")
    public AjaxResult deleteIogInformation(@PathVariable Long id){
        return AjaxResult.success(iogInformationService.deleteIogInformationById(id));
    }
}
